package com.titaniume.java;

/**
 *@program: JavaSenior
 *@description: 案例：创建3个窗口卖票，总票数为100张，使用继承Thread类的方式
 *@author: renfei.huang
 *@create: 2021-09-29 08:57
 */
public class WindowTest  extends Thread{


    public static void main(String[] args) {
        Window t1 = new Window();
        Window t2 = new Window();
        Window t3 = new Window();
        t1.start();
        t2.start();
        t3.start();
    }

}


class Window extends Thread{

   private static int  ticket = 100;

    @Override
    public void run() {
        while (true){
            if(ticket > 0){
                System.out.println(getName() + "：卖票，票号为:"+ticket);
                ticket-- ;
            }else {
                break;
            }
        }
    }
}


